import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';

@Injectable()
export class TaskTabService {
    constructor(private http: HttpClient) { }
    /**获取菜单树 */
    listTabTree(systemUrl: string) {
        return this.http.get('/' + systemUrl + '/api/tasklist/tab/listtree').pipe(
            map((res: Response) => res['data'])
        )
    }
    /** 保存或更新分组 */
    saveUpdateGroup(group, systemUrl: string) {
        return this.http.post('/' + systemUrl + '/api/tasklist/tab/group/saveupdate', group).pipe(
            map((res: Response) => res['data'])
        )
    }
    /** 删除分组 */
    deleteGroup(groupId: number, systemUrl: string) {
        return this.http.get('/' + systemUrl + '/api/tasklist/tab/group/delete?groupId=' + groupId).pipe(
            map((res: Response) => res['data'])
        )
    }
    /** 保存或更新菜单信息 */
    saveUpdate(tab, systemUrl: string) {
        return this.http.post('/' + systemUrl + '/api/tasklist/tab/saveupdate', tab).pipe(
            map((res: Response) => res['data'])
        )
    }
    /** 删除菜单 */
    delete(tabId, systemUrl: string) {
        return this.http.get('/' + systemUrl + '/api/tasklist/tab/delete?tabId=' + tabId).pipe(
            map((res: Response) => res['data'])
        )
    }

    /** 加载菜单 */
    load(tabId) {
        return this.http.get('/punish/api/tasklist/tab/load?tabId=' + tabId).pipe(
            map((res: Response) => res['data'])
        )
    }
}